BigDFT.Interop.DispersionInterop module

Provides an interface to DFTD3/DFTD4.

https://github.com/dftd3/simple-dftd3 https://github.com/dftd4/dftd4

bigdft_to_dftd(sys, version='dftd3')[source]

Converts a BigDFT system to the simple-dftd3 format.

Parameters:
Returns:

a dispersion model for use.

Return type:

(dftd3.interface.DispersionModel)

get_damping_parameters(xc, damping, version='dftd3')[source]

Generate the damping parameters.

Parameters:
  • xc (str) – XC functional

  • damping (str) – for DFTD3 ZeroDampingParam, RationalDampingParam, ModifiedRationalDampingParam, ModifiedZeroDampingParam, OptimizedPowerDampingParam; for DFTD4 DampingParam

  • version (str) – either dftd3 or dftd4.

Returns:

damping parameter object.

Return type:

(dftd3.interface.DampingParam)

pairwise_fragment_interactions(sys, xc, damping, version='dftd3')[source]

Compute the dispersion interaction energy between all pairs of fragments.

Parameters:
  • sys (BigDFT.Systems.System) – the system to compute.

  • xc (str) – XC functional

  • damping (str) – for DFTD3 ZeroDampingParam, RationalDampingParam, ModifiedRationalDampingParam, ModifiedZeroDampingParam, OptimizedPowerDampingParam; for DFTD4 DampingParam

  • version (str) – either dftd3 or dftd4.

Returns:

dictionary of dictionaries with pairwise interactions.

Return type:

(dict)

_example()[source]

The following is an example of module usage:

"""Test the dispersion approach"""
from BigDFT.IO import XYZReader
from BigDFT.Systems import System
from BigDFT.Fragments import Fragment
from copy import deepcopy

# BigDFT Molecule
reader = XYZReader("Ar")
sys = System()
sys["FRA:1"] = Fragment(xyzfile=reader)
sys["FRA:2"] = deepcopy(sys["FRA:1"])
sys["FRA:2"].translate([-2, 0, 0])

# Convert to DispersionModel
model3 = bigdft_to_dftd(sys, version="dftd3")
model4 = bigdft_to_dftd(sys, version="dftd4")

# Lookup the parameters
param3 = get_damping_parameters(xc="pbe", 
                                damping="RationalDampingParam",
                                version="dftd3")
param4 = get_damping_parameters(xc="pbe", 
                                damping="DampingParam",
                                version="dftd4")
# Get the energy
dispersion_energy = model3.get_dispersion(param3, grad=False)["energy"]
print("DFTD3", dispersion_energy)
if abs(dispersion_energy - (-0.0008628959813317974)) > 1e-8:
    raise Exception("Test Failed")

dispersion_energy = model4.get_dispersion(param4, grad=False)["energy"]
print("DFTD4", dispersion_energy)
if abs(dispersion_energy - (-0.0008417917644302559)) > 1e-8:
    raise Exception("Test Failed")

# Pairwise interactions
pe = pairwise_fragment_interactions(sys, xc="blyp",
                                    damping="OptimizedPowerDampingParam",
                                    version="dftd3")
print(pe)
if abs(pe["FRA:1"]["FRA:2"] - (-0.00016771172526004852)) > 1e-8:
    raise Exception("Test Failed")